// ConsolTestGetFileVersion.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <string>
#include <windows.h>

int main(int argc, char* argv[])
{
	printf("Hello World!\n");
	return 0;
}

bool GetVersionInfo(char * lpFileName, std::string& strVersionInfo)
{
	unsigned long nullHandle;
	struct TRANSLATE
	{
		unsigned long languageID;
		unsigned long characterset;
	}Translation;

	long length = GetFileVersionInfoSize(lpFileName, &nullHandle);
		if (length <= 0)
		{
		return false;
	}
	return true;
}

/*
BOOL GetVersionInfo(LPCTSTR lpFileName, std::string& strVersionInfo)
{
         DWORD nullHandle;
         LPVOID versionPtr;
         UINT verLength;
         DWORD length;
         std::string query;

         struct TRANSLATE 
         {
                   WORD languageId;
                   WORD characterSet;
         }Translation;

         
         length = GetFileVersionInfoSize((LPTSTR)lpFileName, &nullHandle);
         if (length <= 0)
                   return FALSE;            

         BYTE *pVersionInfo = new BYTE[length];        
         memset(pVersionInfo, 0, length);
         if (!GetFileVersionInfo((LPTSTR)lpFileName, NULL, length, pVersionInfo)) 
         {
                   SafeFree(pVersionInfo);
                   return FALSE;
         }

         if (!VerQueryValue(pVersionInfo, "\\VarFileInfo\\Translation", &versionPtr, &verLength)) 
         {
                   SafeFree(pVersionInfo);
                   return FALSE;
         }

         Translation = *(TRANSLATE*)versionPtr;

         query.Format(_T("\\StringFileInfo\\%04x%04x\\ProductVersion"),
                                      Translation.languageId, Translation.characterSet);
                   
         if (!VerQueryValue(pVersionInfo, (LPTSTR)(LPCTSTR)query, &versionPtr, &verLength))
         {
                   SafeFree(pVersionInfo);
                   return FALSE;
         }
         
         strVersionInfo = (LPCTSTR)versionPtr;
         SafeFree(pVersionInfo);

         return TRUE;
}
*/